
#ifndef UTILITIES_H
#define UTILITIES_H

namespace ETM
{
	namespace Utils
	{
		const double PI = 3.1415926535;

		template <class T>
		T Clamp(T value, T min, T max)
		{
			T returnVal = value;
			
			if(value < min)
				returnVal = min;
			else if(value > max)
				returnVal = max;

			return returnVal;
		}

		template <class T>
		T ToDegrees(T radians)
		{
			return radians * (180.0 / PI);
		}

		template <class T>
		T ToRadians(T degrees)
		{
			return degrees * (PI / 180.0);
		}

		template <class T>
		T Distance(T val1, T val2)
		{
			return abs(val2 - val1);
		}

		sf::IntRect GetSrcRect(int tilesetWidth, int tileSize, int index);
		int GetRectIndex(int tilesetWidth, int tileSize, sf::IntRect rect);

		sf::Vector2f SpriteCenter(sf::Sprite& sprite);

		void RenderShadowText(sf::RenderWindow& window, sf::String& string);

		sf::Vector2f GetIntersectionDepth(sf::FloatRect rectA, sf::FloatRect rectB);
	}
}

#endif